package com.zsk.spring.restapi.controller;

import com.zsk.spring.restapi.model.MyTest;
import org.springframework.web.bind.annotation.*;

@RestController
public class RestApiController {

    @RequestMapping(value = "/mytest",method = RequestMethod.GET)
    public MyTest restKvMyTest(@RequestParam(value="username",defaultValue = "zsk") String username,
                               @RequestParam(value="age",defaultValue = "15") int age){
        return new MyTest(username,age);

    }

    @RequestMapping(value = "/jsonTest",method = RequestMethod.POST)
    public MyTest restJsonTest(@RequestBody MyTest myTest){
        String username = myTest.getUsername();
        int age = myTest.getAge();
        return new MyTest(username,age+1);
    }
}
